package com.wayhome.springframework.util;

import java.net.URL;

public class ClassUtils {

    public static ClassLoader getDefaultClassLoader() {
        ClassLoader cl = null;
        try {
            cl = Thread.currentThread().getContextClassLoader();
        } catch (Throwable ex) {

        }
        if (cl == null){
            cl =ClassUtils.class.getClassLoader();
        }
        return cl;
    }

    public static void main(String[] args) {
        ClassLoader classLoader = ClassUtils.class.getClassLoader();
        String path = classLoader.getResource("spring.xml").getPath();
        System.out.println(path);
        String path1 = classLoader.getResource("").getPath();
        System.out.println(path1);
        URL resource = classLoader.getResource("classpath:spring.xml");
        System.out.println(resource);
    }
}
